public class ListenContact implements ContactListener
{
  ListenContact()
  {
  }

  /**
   * Called when a contact point is added, ie. when colliding.
   * This includes the geometry and the forces.
   */
  public void add(ContactPoint cp)
  {
    //println("Ouch!");
    //DumpContactPoint(cp);
    boxDetection(cp.shape1);
    boxDetection(cp.shape2);
  }
  
  
  void boxDetection(Shape s)
  {
    Body b = s.getBody();
    Object o = b.getUserData();
    if(o!=null)
    {
        String c = o.getClass().getName();
        if(c.contains("Box"))
        {
            Box p = (Box) o;
            p.hit();
        }
    }
  }

  /**
   * Called when a contact point persists, ie. contact is maintained.
   * This includes the geometry and the forces.
   */
  public void persist(ContactPoint cp)
  {
    //println("Sticky, eh?");
    //DumpContactPoint(cp);
  }

  /**
   * Called when a contact point is removed, ie. contact is broken.
   * This includes the last computed geometry and forces.
   */
  public void remove(ContactPoint cp)
  {
    //println("Good riddance!");
    //DumpContactPoint(cp);
  }

  /**
   *
   */
  public void result(ContactResult cr)
  {
    //DumpContactResult(cr);
  }
}
